package com.wuxb.util.disruptor.main;

import com.lmax.disruptor.dsl.Disruptor;

import java.util.concurrent.CountDownLatch;

public class TradePublisher implements Runnable {

    Disruptor<Person> disruptor;
    private CountDownLatch latch;

    private static int LOOP=10;//模拟百万次交易的发生

    public TradePublisher(CountDownLatch latch, Disruptor<Person> disruptor) {
        this.disruptor=disruptor;
        this.latch=latch;
    }

    @Override
    public void run() {
        for(int i=0;i<LOOP;i++){
            Product product = new Product(1);
            disruptor.publishEvent(product);
        }
        latch.countDown();
    }


}

